using NodeCanvas.Variables;
using UnityEngine;

namespace NodeCanvas.BehaviourTrees
{
	[AddComponentMenu("")]
	[Name("Set")]
	[Category("Decorators")]
	[Description("Set another Agent for the rest of the Tree dynamicaly from this point and on. All nodes under this will be executed for the new agent")]
	[Icon("Set")]
	public class BTSetter : BTDecorator
	{
		public BBGameObject agentToSet;

		protected override Status OnExecute(Component agent, Blackboard blackboard)
		{
			if (!base.decoratedConnection)
			{
				return Status.Resting;
			}
			if (agentToSet.value != null)
			{
				agent = agentToSet.value.transform;
			}
			return base.decoratedConnection.Execute(agent, blackboard);
		}
	}
}
